import { find } from 'lodash';

export const getTableColumns = ({ params }) => [
	{
		title: "岗位ID",
		dataIndex: "id",
		width: 140,
		ellipsis: true
	},
	{
		title: "岗位名称",
		dataIndex: "name",
		width: 140,
		ellipsis: true
	},
	{
		title: "显示顺序",
		dataIndex: "sort",
		width: 140,
		ellipsis: true
	},
	{
		title: "岗位状态",
		dataIndex: "status",
		width: 140,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(POST_STATUS, (item: any) => `${item.value}` === `${record.status}`)
			return (
				<span>
					{result?.label}
				</span>
			)
		}
	},
	{
		title: "创建日期",
		dataIndex: "createTime",
		width: 140,
		ellipsis: true
	},
];

export const POST_STATUS = [
	{ label: '停用', value: 0 },
	{ label: '正常', value: 1 }
]

export const getSearchColumns = () => [
	// {
	// 	type: "input",
	// 	placeholder: "岗位ID",
	// 	name: "id"
	// },
	{
		type: "input",
		placeholder: "岗位名称",
		name: "name"
	},
	{
		type: "select",
		placeholder: "岗位状态",
		name: "status",
		options: POST_STATUS
	},
]

export const getCreateColumns = () => {
	return [
		{
			type: "input",
			placeholder: "岗位名称",
			label: "岗位名称",
			name: "name",
			rules: [{ required: true, message: '这是必填项' }]
		},
		{
			type: "input",
			placeholder: "权限代码",
			label: "权限代码",
			name: "code",
			rules: [{ required: true, message: '这是必填项' }]
		},
		{
			type: "radioGroup",
			placeholder: "状态",
			label: "状态",
			name: "status",
			options: POST_STATUS,
		},
		{
			type: "input",
			placeholder: "排序",
			label: "排序",
			name: "sort",
		},
	]
}